// gfx.h - WGAL Graphics header
#ifndef WGAL_GFX_H
#define WGAL_GFX_H

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <wgal/common.h>

#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus

/*
// Texture APIs
WGALAPI WGALUInt32 wgalLoadTexture(WGALCString path);
WGALAPI WGALUInt32 wgalLoadTextureFromMemory(const WGALVoid * mem, WGALUInt32 size);
WGALAPI WGALVoid wgalFreeTexture(WGALUInt32 texId);
WGALAPI WGALVoid wgalFreeTextureAll();
*/

// Image APIs
WGALAPI WGALUInt32 wgalLoadImage(WGALCString path);
WGALAPI WGALUInt32 wgalLoadImageFromMemory(const WGALVoid * mem, WGALUInt32 size);
WGALAPI WGALVoid wgalFreeImage(WGALUInt32 imgId);
WGALAPI WGALVoid wgalFreeImageAll();

// Primitive APIs
//WGALAPI WGALVoid wgalBegin();
//WGALAPI WGALVoid wgalVertex();
//WGALAPI WGALVoid wgalEnd();

// Font APIs
WGALAPI WGALUInt32 wgalLoadFont(WGALCString face,
								WGALUInt32 height,
								WGALBool bold,
								WGALBool italic);
WGALAPI WGALUInt32 wgalMeasureText(WGALUInt32 fontId,
								 WGALCString text);
WGALAPI WGALUInt32 wgalGetFontHeight(WGALUInt32 fontId);
WGALAPI WGALVoid wgalDrawText(WGALUInt32 fontId,
							  WGALCString text,
							  WGALLocationPtr pos,
							  WGALUInt32 align,
							  WGALColor color
							  );
WGALAPI WGALVoid wgalTextBox(WGALUInt32 fontId,
							 WGALCString text,
							 WGALRectPtr rect,
							 WGALUInt32 align,
							 WGALColor color,
							 WGALBool word_break
							 );
WGALAPI WGALVoid wgalFreeFont(WGALUInt32 fontId);
WGALAPI WGALVoid wgalFreeFontAll();

// Screen APIs
WGALAPI WGALVoid wgalSetBlendMode(WGALUInt32 mode);
WGALAPI WGALVoid wgalClear(WGALColor color);
/*
WGALAPI WGALVoid wgalBlit(WGALUInt32 imgId,
						  WGALRectPtr srcRect,
						  WGALRectPtr destRect,
						  WGALFloat depth);
						  */
#define wgalBlit(imgId,/* image id */			\
	/*srcRect,/* source rect */					\
	/*destRect,/* destination rect */			\
	x,/* x coordinate */						\
	y,/* y coordinate */						\
	width,/* width of the image */				\
	height/*,/* height of the image */			\
	/*depth/* depth */							\
	)											\
	wgalBlitEx(imgId,/* image id */				\
	/*srcRect,/* source rect */					\
	/*destRect,/* destination rect */			\
	(float)(x),/* x coordinate */				\
	(float)(y),/* y coordinate */				\
	(float)(width),/* width of the image */		\
	(float)(height),/* height of the image */	\
	WGAL_FLIP_NONE,/* flip */					\
	COLOR_WHITE,/* tint */						\
	0.0f,/* rotation */							\
	NULL/*,/* pivot */							\
	/*depth/* depth */							\
	)

WGALAPI WGALVoid wgalBlitEx(WGALUInt32 imgId,
							//WGALRectPtr srcRect,
							WGALFloat x,
							WGALFloat y,
							WGALFloat width,
							WGALFloat height,
							WGALUInt32 flip,
							WGALColor tint,
							WGALFloat rotation,
							WGALLocationPtr pivot/*,
							WGALFloat depth*/);

WGALAPI WGALVoid wgalPresent();

#ifdef __cplusplus
}
#endif // __cplusplus

// blend mode constants
#define WGAL_BLEND_NONE			0
#define WGAL_BLEND_ALPHA		1
#define WGAL_BLEND_ADDITIVE		2

// flip mode constants
#define WGAL_FLIP_NONE			0x00
#define WGAL_FLIP_HORIZONTAL	0x01
#define WGAL_FLIP_VERTICAL		0x02
#define WGAL_FLIP_BOTH			0x03

// alignment constants
#define WGAL_ALIGN_DEFAULT		0x00
// horizontal
#define WGAL_ALIGN_LEFT			0x00
#define WGAL_ALIGN_CENTER		0x01
#define WGAL_ALIGN_RIGHT		0x02
// vertical
#define WGAL_ALIGN_TOP			0x00
#define WGAL_ALIGN_VCENTER		0x04
#define WGAL_ALIGN_BOTTOM		0x08

#endif // !WGAL_GFX_H